
/*==============================================================*/
/* Table: config                                                */
/*==============================================================*/
create table config (
   Config_ID            int                  identity,
   "Key"                varchar(20)          null,
   Value                varchar(20)          null,
   constraint PK_CONFIG primary key (Config_ID)
)
go

/*==============================================================*/
/* Table: jc_dept                                               */
/*==============================================================*/
create table dbo.jc_dept (
   id                   int                  identity(1, 1),
   name                 nvarchar(255)         not null,
   supid                int                  null,
   supname              nvarchar(255)         null,
   pos                  int                  null,
   dept_id              nvarchar(255)         not null,
   catalogy             nvarchar(50)          null,
   isroot               int                  null,
   descn                nvarchar(255)         null,
   endflag              nvarchar(255)         null,
   status               nvarchar(255)         null,
   constraint PK__system_depts__119F9925 primary key (id)
         on "PRIMARY",
   constraint UQ__system_depts__1293BD5E unique (dept_id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: jc_duty                                               */
/*==============================================================*/
create table dbo.jc_duty (
   id                   int                  identity(1, 1),
   name                 nvarchar(50)          not null,
   lev                  int                  not null,
   descn                nvarchar(255)         null,
   dept_id              int                  null,
   constraint PK__system_dutys__184C96B4 primary key (id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: jc_user                                               */
/*==============================================================*/
create table dbo.jc_user (
   id                   int                  identity(1, 1),
   name                 nvarchar(50)          not null,
   sex                  int                  null,
   birthday             datetime             null,
   pos                  int                  null,
   createtime           datetime             null,
   loginid              nvarchar(50)          not null,
   password             nvarchar(255)         not null,
   status               nvarchar(2)           null,
   isopen               nvarchar(255)         null,
   mobile               nvarchar(25)          null,
   shortnumber          nvarchar(80)          null,
   email                nvarchar(50)          null,
   email2               nvarchar(50)          null,
   homephone            nvarchar(50)          null,
   officephone          nvarchar(50)          null,
   officeaddress        nvarchar(100)         null,
   address              nvarchar(100)         null,
   fax                  nvarchar(100)         null,
   qq                   nvarchar(25)          null,
   msn                  nvarchar(50)          null,
   descn                nvarchar(255)         null,
   lastlogintime        datetime             null,
   lastloginip          nvarchar(50)          null,
   dept_id              int                  null,
   duty_id              int                  null,
   constraint PK__system_users__3B95D2F1 primary key (id)
         on "PRIMARY",
   constraint UQ__system_users__3C89F72A unique (loginid)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_agent                                              */
/*==============================================================*/
create table dbo.wf_agent (
   id                   int                  identity(1, 1),
   user_id              int                  null,
   fromuser_id          int                  null,
   flow_pid             int                  null,
   createdate           datetime             null,
   startdate            datetime             null,
   enddate              datetime             null,
   status               int                  null,
   constraint PK__workflow_flowage__1446FBA6 primary key (id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_form                                               */
/*==============================================================*/
create table dbo.wf_form (
   form_id              int                  identity(1, 1),
   name                 nvarchar(40)          not null,
   catalogy             nvarchar(50)          null,
   dept_id              int                  not null,
   user_id              int                  not null,
   location             nvarchar(200)        null,
   pos                  int                  null,
   createtime           datetime             null,
   lasttime             datetime             null,
   descn                nvarchar(200)         null,
   user_name            nvarchar(255)        null,
   constraint PK__workflow_flowtyp__1BE81D6E primary key (form_id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_formfield                                          */
/*==============================================================*/
create table dbo.wf_formfield (
   formfield_id         int                  identity(1, 1),
   form_id              int                  null,
   name                 nvarchar(50)          not null,
   fieldtype            nvarchar(50)          null,
   formtype             nvarchar(50)          null,
   webtype              nvarchar(10)          null,
   valuescale           nvarchar(50)          null,
   isquery              int                  null,
   valuedefault         nvarchar(50)          null,
   inputfrom            int                   null,
   fromparams           nvarchar(255)        null,
   fromvalue            nvarchar(200)        null,
   descn                nvarchar(200)         null,
   constraint PK__workflow_flowfie__18178C8A primary key (formfield_id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_ins                                                */
/*==============================================================*/
create table dbo.wf_ins (
   uniqueid             uniqueidentifier     not null,
   wf_id                int                  null,
   user_id              int                  null,
   name                 nvarchar(200)        collate Chinese_PRC_CI_AS null,
   createdate           datetime             null,
   lastdate             datetime             null,
   flow_state           int                  null,
   result               nvarchar(200)        null,
   sqlargs              nvarchar(200)        null,
   constraint PK__workflow_file__7B7B4DDC primary key (uniqueid)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_insvalue                                           */
/*==============================================================*/
create table wf_insvalue (
   insvalue_id          int                  identity,
   task_id              int                  null,
   fieldName            nvarchar(255)        null,
   fieldValue           nvarchar(1000)       null,
   fieldType            nvarchar(255)        null,
   constraint PK_WF_INSVALUE primary key (insvalue_id)
)
go

/*==============================================================*/
/* Table: wf_log                                                */
/*==============================================================*/
create table dbo.wf_log (
   id                   int                  identity(1, 1),
   table_id             int                  null,
   table_name           nvarchar(50)          null,
   modifytime           datetime             null,
   info                 nvarchar(500)         null,
   user_id              int                  null,
   constraint PK__workflow_log__1FB8AE52 primary key (id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_step                                               */
/*==============================================================*/
create table dbo.wf_step (
   step_id              int                  identity(1, 1),
   steptype_id          int                  null,
   wf_id                int                  null,
   dept_id              int                  null,
   team_id              int                  null,
   users                nvarchar(1024)        null,
   name                 nvarchar(40)          null,
   descn                nvarchar(200)         null,
   false_wfnid          nvarchar(150)         null,
   true_wfnid           nvarchar(50)          null,
   step_type            nvarchar(255)        null,
   state                nvarchar(255)        null,
   constraint PK__workflow_step__2B2A60FE primary key (step_id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_steptype                                           */
/*==============================================================*/
create table dbo.wf_steptype (
   id                   int                  identity(1, 1),
   name                 nvarchar(40)          null,
   descn                nvarchar(100)         null,
   constraint PK__workflow_steptyp__2D12A970 primary key (id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_task                                               */
/*==============================================================*/
create table dbo.wf_task (
   task_id              int                  not null,
   uniqueid             uniqueidentifier     null,
   step_id              int                  null,
   taskname             nvarchar(255)        null,
   state                nvarchar(255)        null,
   processword          nvarchar(1023)        null,
   processtype          nvarchar(255)        null,
   user_id              int                  null,
   fqrcode              int                  null,
   starttime            datetime             null,
   checkintime          datetime             null,
   senttime             datetime             null,
   days                 int                  null,
   constraint PK__workflow_fileinb__031C6FA4 primary key (task_id)
         on "PRIMARY"
)
on "PRIMARY"
go

/*==============================================================*/
/* Table: wf_wf                                                 */
/*==============================================================*/
create table dbo.wf_wf (
   wf_id                int                  identity(1, 1),
   form_id              int                  null,
   name                 nvarchar(40)          not null,
   pos                  int                  null,
   ver                  int                  not null,
   usever               int                  not null,
   catalogy             nvarchar(50)          null,
   createtime            datetime             null,
   lasttime             datetime             null,
   creater_id           int                  null,
   creater_name         nvarchar(255)        null,
   lastuser_id          int                  null,
   lastuser_name        nvarchar(255)        null,
   users                nvarchar(255)         null,
   depts                nvarchar(255)         null,
   status               int                  not null,
   wfdefinition         nvarchar(max)        null,
   wfrule               nvarchar(max)        null,
   wflayout             nvarchar(Max)        null,
   descn                nvarchar(600)         null,
   constraint PK__workflow__6B44E613 primary key (wf_id)
         on "PRIMARY"
)

/*==============================================================*/
/* Table: wf_module                                             */
/*==============================================================*/
create table wf_template (
   wftemplate_id            int                  identity,
   wftemplate_name      nvarchar(40)         null,
   wfdefinition               nvarchar(max)        null,
   wfrule                      nvarchar(max)        null,
   wflayout                   nvarchar(max)        null,
   create_time             nvarchar(40)         null,
   creater_name          nvarchar(40)         null,
   creater_id               nvarchar(40)         null,
   constraint PK_WF_TEMPLATE primary key (wftemplate_id)
)


/*==============================================================*/
/* Table: system_calen                                          */
/*==============================================================*/
create table system_calen (
   id                   int                  identity,
   note_text            varchar(700)         not null,
   note_time            varchar(50)          not null,
   text_msg             varchar(10)          not null,
   user_id              int                  not null
)

/*==============================================================*/
/* Table: bbs_card                                              */
/*==============================================================*/
create table bbs_card (
   card_id              int                  identity,
   user_id              int                  null,
   card_title           nvarchar(50)         not null,
   card_text            nvarchar(Max)        not null,
   update_time          varchar(50)          not null,
   card_state           nvarchar(20)         null,
   reply_count          int                  null,
   constraint PK_BBS_CARD primary key (card_id)
)
go

alter table bbs_card
   add constraint FK_BBS_CARD_REFERENCE_SYSTEM_U foreign key (user_id)
      references dbo.system_users (id)
go

/*==============================================================*/
/* Table: bbs_reply_card                                        */
/*==============================================================*/
create table bbs_reply_card (
   reply_id             int                  identity,
   card_id              int                  null,
   user_id              int                  null,
   reply_time           varchar(20)          not null,
   reply_text           nvarchar(Max)        not null,
   constraint PK_BBS_REPLY_CARD primary key (reply_id)
)
go

alter table bbs_reply_card
   add constraint FK_BBS_REPL_REFERENCE_SYSTEM_U foreign key (user_id)
      references dbo.system_users (id)
go

alter table bbs_reply_card
   add constraint FK_BBS_REPL_REFERENCE_BBS_CARD foreign key (card_id)
      references bbs_card (card_id)
go

/*==============================================================*/
/* Table: system_menu                                           */
/*==============================================================*/
create table system_menu (
   menu_id              int                  null,
   menu_name            nvarchar(50)         null,
   menu_supid           int                  null
)
go

/*==============================================================*/
/* Table: user_file                                             */
/*==============================================================*/
create table user_file (
   file_id              int                  identity,
   file_name            nvarchar(50)         null,
   file_replacename     nvarchar(50)         null,
   file_ctime           nvarchar(20)         null,
   file_size            int                  null,
   file_path            nvarchar(100)        null,
   user_id              int                  null,
   file_mime            nvarchar(20)         null,
   file_descn           nvarchar(200)        null,
   file_ext             nvarchar(10)         null,
   file_catalog     nvarchar(20)         null,
   constraint PK_USER_FILE primary key (file_id)
)
create table jc_msgmx (
   msgmx_id             int                  identity,
   msg_id               int                  null,
   receiver_id          int                  null,
   msgmx_isread         int                  null,
   constraint PK_JC_MSGMX primary key (msgmx_id)
)